package com.cib.process.chat.core.handler;

import com.cib.process.bean.Actions;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

@Component
public class ActionHandlerFactory {
    /**1007-转人工*/
    @Autowired
    private ActionHandler custSvcActionHandler;
    /**1003-金额处理器*/
    @Autowired
    private ActionHandler moneyActionHandler;
    /**1001-数字卡号等处理*/
    @Autowired
    private ActionHandler numericLetterActionHandler;
    /**1002-密码处理*/
    @Autowired
    private ActionHandler passwordActionHandler;
    /**1004-短信认证码处理*/
    @Autowired
    private ActionHandler smsActionHandler;
    /***/
    @Autowired
    private ActionHandler noneActionHandler;
    /**1005-tts播报处理*/
    @Autowired
    @Qualifier("ttsActionHandler")
    private ActionHandler ttsActionHandler;
    /**1006-满意度调查*/
    @Autowired
    private ActionHandler satifactionActionHandler;
    /***/
    @Autowired
    private ActionHandler cvvActionHandler;
    /**1009-挂机释放*/
    @Autowired
    @Qualifier("ttsActionHandler")
    private ActionHandler overActionHandler;




    public ActionHandler chooseActionHandler(String action) {
        if (StringUtils.isNotBlank(action)){
            Actions actions = Actions.instanceOf(action);
            switch (actions){
                case NUM_CHAR:
                    return this.numericLetterActionHandler;
                case PWD:
                    return this.passwordActionHandler;
                case SUM:
                    return this.moneyActionHandler;
                case SMS:
                    return this.smsActionHandler;
                case CUST_SVC:
                    return this.custSvcActionHandler;
                case TTS:
                    return this.ttsActionHandler;
                case ASR:
                    return this.satifactionActionHandler;   //满意度调查
                case IVR:
                    return overActionHandler;
                case HANGUP:
                    return overActionHandler;
                case CVV2:
                    return this.cvvActionHandler;
                case ERROR:
                    return this.overActionHandler;
            }
        }
        return this.noneActionHandler;

    }
}
